<?php

class Model_Project extends Zend_Db_Table_Abstract
{
    protected $_name = 'project';
    public function __construct()
    {
        $parameters =array(
                        'host'     => '127.0.0.1',
                        'username'   => 'pro_cmdb_server',
                        'password' => '0aFswAW7P2N8yVMdADXt',
                        'dbname'   => 'pro_cmdb_server',
                        'charset'  => "UTF8",
                        'adapter'  => 'Pdo_Mysql'
                   );
         try {
             $db = Zend_Db::factory('Pdo_Mysql', $parameters);
             $db->getConnection();
         } catch (Zend_Db_Adapter_Exception $e) {
    
         } catch (Zend_Exception $e) { 
         }
         //Zend_Db_Table::setDefaultAdapter($db);
         $this->_setAdapter($db);
    }
    public function getDataByEquipmentId($equipmentId){
        
        $equipmentId = (int)($equipmentId);
        $query = $this->select()
                        ->setIntegrityCheck(false)
                        ->from(array('p' => $this->_name), array('p.projectName'))
                        ->joinLeft(array('ep'=>'equipment_project'), 'p.projectId = ep.projectId', array())
                        ->where('ep.equipmentId = ?',$equipmentId)
                        ->group('p.projectName');
                        
        return $this->fetchAll($query)->toArray();
    }

}

























